# 修复Java文件中的@Valid注解语法错误
$javaFiles = Get-ChildItem -Path "src\main\java" -Filter "*.java" -Recurse
$fixedCount = 0

foreach ($file in $javaFiles) {
    $content = Get-Content $file.FullName -Raw -Encoding UTF8
    $originalContent = $content
    
    # 修复 @Valid        Map<String, Object> response = new HashMap<>(); 模式
    $content = $content -replace '@Valid\s+Map<String, Object> response = new HashMap<>\(\);', '@RequestBody Object request) {\r\n        Map<String, Object> response = new HashMap<>();'
    
    # 修复特殊情况：AuthController中的wxLogin方法
    $content = $content -replace 'public ResponseEntity<Map<String, Object>> wxLogin\(@Valid\s+Map<String, Object> response = new HashMap<>\(\);', 'public ResponseEntity<Map<String, Object>> wxLogin(@Valid @RequestBody WxLoginRequest request) {\r\n        Map<String, Object> response = new HashMap<>();'
    
    if ($content -ne $originalContent) {
        Set-Content -Path $file.FullName -Value $content -Encoding UTF8 -NoNewline
        Write-Host "Fixed: $($file.FullName)"
        $fixedCount++
    }
}

Write-Host "Total files fixed: $fixedCount"